package com.sds.replicator.servlets;

import com.google.inject.Inject;
import com.google.inject.Singleton;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by IntelliJ IDEA.
 * User: sdsbirdman
 * Date: 7/10/11
 * Time: 9:08 AM
 * To change this template use File | Settings | File Templates.
 */
@Singleton
public class MobileFacebookReplicator extends FetcherServlet {
    public static String LOCAL_PATH = "/mfb";

    @Inject
    public MobileFacebookReplicator() {
        super(LOCAL_PATH, "http://m.facebook.com/");
    }

    @Override
    protected String transformURL(String targetURL, HttpServletRequest incomingRequest) {
        if (targetURL != null) {
            targetURL = targetURL.replace("http://www.facebook.com/mfb?url=","");
            targetURL = targetURL.replace("/mfb?url=", "/");
            targetURL = targetURL.replace("www.facebook.com", "m.facebook.com");
        }
        return super.transformURL(targetURL, incomingRequest);
    }
}
